var express = require('express');
var router = express.Router();
//接收服务层函数
const {getAll2,addOne2,deleteOne2,getOne2,upDateOne2,getAllGoods2}=require("../server/goodsService")

//获取商品数据
router.get('/getAll', async(req, res, next) =>{  
       
    const data=await getAll2(req.query);
    res.send(data)
});
//新增商品数据
router.post("/addOne",async(req,res,next)=>{
    const result=await addOne2(req.body)
    res.send(result)
})
//删除数据
router.delete("/deleteOne",async(req,res,next)=>{
    const result=await deleteOne2(req.body)
    res.send(result)
})
//获取一个商品数据
router.get("/getOne",async(req,res,next)=>{
    const data=await getOne2(req.query);
    res.send(data)
})
//修改数据
router.put("/upDateOne",async(req,res,next)=>{
    const result=await upDateOne2(req.body)
    res.send(result)
})
//获取全部商品
router.get("/getAllGoods",async (req,res,next)=>{
    const result=await getAllGoods2()
    res.send(result)
})
module.exports = router;